{{useCss "/app-pages/css/user.scss","/user/:user_page?"}}
<div id="user">
    {{#teleporter "user"}}
</div>

<script type="text/vm">
function(vm) {
	//用户信息是否已经载入
	var _loginer_load = false;
	//用户是否登录
	var _has_loginer = false;
	eventManager.after("getLoginer", function() {
		_loginer_load = true;
		_has_loginer = true;
	});
	eventManager.after("getLoginerError", function() {
		_loginer_load = true;
		_has_loginer = false;
		if (Path._current_page.indexOf("/user/") === 0 && Path._current_page !== "/user/main") {
			Path.jump("/user/main.html");
		}
	}, true);
	Path.registerjSouperRoute("/user/:user_page?", function(loc) {
		var user_page = this.params.user_page;//这里还没触发Route，所以不能用Path._current_page来判断
		if (_loginer_load && !_has_loginer && user_page !== "main.html") {
			Path.jump("/user/main.html");
			return;
		}
		return ({
			xxxxx:'xxxx',
			stop_emit: true, //因为是2级路由，事件已经出发过了，阻止事件再次捕获触发
			href: loc.href,
			html: "/app-pages/pages/user/",
			js: "/app-pages/js/user/",
			css: "/app-pages/css/user/",
			prefix: "/user/", //URL-pathname中无用的前缀部分，用来过滤href得出pagename
			tel: "user",
			default: "main",
			pagename_handler: function(pagename) { //过滤出来的pagename在这里处理·二次处理pagename
				//过滤掉后缀
				return jSouper.$.lst(pagename, ".") || pagename;
			},
			index: 1,
			vm: vm
		});
	});
}
</script>